/**
 * <p>Copyright (c) 2010 by DRM. </p>
 */

package com.android.drm;

import com.android.drm.help.CustomDialog;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.View;

/**
 * <p><b>CLASS:</b> com.android.drm.ChartBaseBuilder</p>
 *
 * ...........................................................................
 * <p><b>DESCRIPTION:</b><br/>
 * Base class for charting.
 * </p>
 * 
 * ...........................................................................
 * <p><b>MODIFICATION HISTORY:</b>
 * <p>[2010/07/29] e2005g: Initial version.</p>
 * </p>
 * 
 * ...........................................................................
 * @author e2005g
 * @since 1.0
 */

public abstract class ChartBaseBuilder extends Activity {
	
	private static final int HELP_DIALOG = 1;
	private static final int ABOUT_DIALOG = 2;

	public void myClickHandler(View v) {
		switch (v.getId()) {
		case R.id.helpButton:
			ChartBaseBuilder.this.showDialog(HELP_DIALOG);	
			break;
		case R.id.homeButton:
            Intent intent = new Intent(ChartBaseBuilder.this, HomeScreen.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); 
            startActivity(intent);
			break;
		case R.id.logo:
			ChartBaseBuilder.this.showDialog(ABOUT_DIALOG);	
			break;
		default:
			break;
		}
	}
	
    public Dialog onCreateDialog(int dialogId) {
    	Dialog dialog = null;
    	switch (dialogId) {
	    	case HELP_DIALOG :
				CustomDialog.Builder customBuilder = new
				CustomDialog.Builder(ChartBaseBuilder.this);
				customBuilder.setMessage(R.string.ChartBaseBuilderHelpMsg)
					.setPositiveButton("Close", new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int which) {
							dialog.dismiss();
						}
					});
	            dialog = customBuilder.create();
	    		break;
	    	case ABOUT_DIALOG : 
				CustomDialog.Builder aboutBuilder = new
				CustomDialog.Builder(ChartBaseBuilder.this);
				aboutBuilder.setMessage(R.string.AboutMsg)
					.setPositiveButton("Close", new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int which) {
							dialog.dismiss();
						}
					});
	            dialog = aboutBuilder.create();
	    		break;
    	}
    	return dialog;
    }
	
	private void setIntentExtras (Intent intent) {
		intent.putExtras(getIntent());
		intent.putExtra("averageTitle", "Average Response");
		intent.putExtra("totalTitle", "Total Response");
	}

}

